-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(j-s): Allow district court assistant to act as registrar in R cases #17772
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request introduces modifications to the judicial system's backend and web applications, focusing on expanding user role validation and access criteria. The changes primarily affect how district court users, particularly assistants and registrars, can interact with cases. The modifications simplify role-based access logic, broaden the eligibility for case assignments, and adjust filtering mechanisms across multiple components of the judicial system application. Changes
Possibly related PRs
Suggested Labels
Suggested Reviewers
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
View your CI Pipeline Execution ↗ for commit 9ef5772.
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/judicial-system/backend/src/app/modules/case/filters/cases.filter.ts (1)
111-142
: LGTM! Query filter logic simplified.The consolidation of query options improves code maintainability. Consider extracting the state arrays into constants for better reusability.
+const RESTRICTION_INVESTIGATION_STATES = [ + CaseState.DRAFT, + CaseState.SUBMITTED, + CaseState.RECEIVED, + CaseState.ACCEPTED, + CaseState.REJECTED, + CaseState.DISMISSED, +] + +const INDICTMENT_STATES = [ + CaseState.SUBMITTED, + CaseState.WAITING_FOR_CANCELLATION, + CaseState.RECEIVED, + CaseState.COMPLETED, +] options.push({ [Op.or]: [ { [Op.and]: [ { type: [...restrictionCases, ...investigationCases] }, { - state: [ - CaseState.DRAFT, - CaseState.SUBMITTED, - CaseState.RECEIVED, - CaseState.ACCEPTED, - CaseState.REJECTED, - CaseState.DISMISSED, - ], + state: RESTRICTION_INVESTIGATION_STATES, }, ], }, { [Op.and]: [ { type: indictmentCases }, { - state: [ - CaseState.SUBMITTED, - CaseState.WAITING_FOR_CANCELLATION, - CaseState.RECEIVED, - CaseState.COMPLETED, - ], + state: INDICTMENT_STATES, }, ], }, ], })
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
apps/judicial-system/backend/src/app/modules/case/case.controller.ts
(1 hunks)apps/judicial-system/backend/src/app/modules/case/filters/case.filter.ts
(0 hunks)apps/judicial-system/backend/src/app/modules/case/filters/cases.filter.ts
(1 hunks)apps/judicial-system/backend/src/app/modules/case/filters/test/districtCourtUserFilter.spec.ts
(1 hunks)apps/judicial-system/web/src/routes/Court/components/ReceptionAndAssignment/SelectCourtOfficials/SelectCourtOfficials.tsx
(2 hunks)apps/judicial-system/web/src/routes/Shared/Cases/useFilter.tsx
(1 hunks)
💤 Files with no reviewable changes (1)
- apps/judicial-system/backend/src/app/modules/case/filters/case.filter.ts
🧰 Additional context used
📓 Path-based instructions (5)
apps/judicial-system/backend/src/app/modules/case/case.controller.ts (1)
Pattern apps/**/*
: "Confirm that the code adheres to the following:
- NextJS best practices, including file structure, API routes, and static generation methods.
- Efficient state management and server-side rendering techniques.
- Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/web/src/routes/Shared/Cases/useFilter.tsx (1)
Pattern apps/**/*
: "Confirm that the code adheres to the following:
- NextJS best practices, including file structure, API routes, and static generation methods.
- Efficient state management and server-side rendering techniques.
- Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/case/filters/test/districtCourtUserFilter.spec.ts (1)
Pattern apps/**/*
: "Confirm that the code adheres to the following:
- NextJS best practices, including file structure, API routes, and static generation methods.
- Efficient state management and server-side rendering techniques.
- Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/web/src/routes/Court/components/ReceptionAndAssignment/SelectCourtOfficials/SelectCourtOfficials.tsx (1)
Pattern apps/**/*
: "Confirm that the code adheres to the following:
- NextJS best practices, including file structure, API routes, and static generation methods.
- Efficient state management and server-side rendering techniques.
- Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/case/filters/cases.filter.ts (1)
Pattern apps/**/*
: "Confirm that the code adheres to the following:
- NextJS best practices, including file structure, API routes, and static generation methods.
- Efficient state management and server-side rendering techniques.
- Optimal use of TypeScript for component and utility type safety."
📓 Learnings (1)
apps/judicial-system/backend/src/app/modules/case/filters/test/districtCourtUserFilter.spec.ts (1)
Learnt from: gudjong
PR: island-is/island.is#16389
File: apps/judicial-system/backend/src/app/modules/case/test/limitedAccessCaseController/getCaseFilesRecordPdfRolesRules.spec.ts:1-1
Timestamp: 2024-11-12T15:15:20.157Z
Learning: The usage of `defenderRule` in the following test files is intentional and should remain unchanged:
- `apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/createPresignedPostRolesRules.spec.ts`
- `apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/deleteCaseFileRolesRules.spec.ts`
- `apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/createCaseFileRolesRules.spec.ts`
- `apps/judicial-system/backend/src/app/modules/file/test/limitedAccessFileController/getCaseFileSignedUrlRolesRules.spec.ts`
- `apps/judicial-system/backend/src/app/modules/case/test/limitedAccessCaseController/getRulingPdfRolesRules.spec.ts`
- `apps/judicial-system/backend/src/app/modules/case/test/limitedAccessCaseController/getRequestPdfRolesRules.spec.ts`
- `apps/judicial-system/backend/src/app/modules/case/test/limitedAccessCaseController/getCourtRecordPdfRolesRules.spec.ts`
- `apps/judicial-system/backend/src/app/modules/case/test/limitedAccessCaseController/getByIdRolesRules.spec.ts`
- `apps/judicial-system/backend/src/app/modules/case/test/limitedAccessCaseController/getAllFilesZipRolesRules.spec.ts`
- `apps/judicial-system/backend/src/app/modules/case/test/caseController/getAllRolesRules.spec.ts`
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: tests (judicial-system-backend)
🔇 Additional comments (5)
apps/judicial-system/backend/src/app/modules/case/filters/test/districtCourtUserFilter.spec.ts (1)
65-65
: Great improvement in test coverage!Using
districtCourtRoles
instead of hardcoded roles enhances maintainability and ensures comprehensive testing across all district court roles.apps/judicial-system/web/src/routes/Shared/Cases/useFilter.tsx (1)
82-82
: LGTM! Aligns with PR objectives.The change correctly removes filter restrictions for district court assistants while maintaining necessary restrictions for prosecutor representatives.
Run this script to verify the impact:
✅ Verification successful
Verification successful: District court assistants have unrestricted access
The code correctly implements the intended changes:
- No filtering restrictions exist for district court assistants
- Only prosecutor representatives have specific filtering limitations
- The default behavior grants full access to all case types
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that district court assistants have access to all case types # Test: Search for any remaining restrictions on DISTRICT_COURT_ASSISTANT rg -A 5 "DISTRICT_COURT_ASSISTANT.*INVESTIGATION|DISTRICT_COURT_ASSISTANT.*INDICTMENT"Length of output: 88
Script:
#!/bin/bash # Get the complete useFilter.tsx file echo "=== useFilter.tsx content ===" cat apps/judicial-system/web/src/routes/Shared/Cases/useFilter.tsx echo -e "\n=== Searching for UserRole-based filtering ===" rg "UserRole\." -A 3 apps/judicial-system/web/src/routes/Shared/Cases/ echo -e "\n=== Searching for DISTRICT_COURT_ASSISTANT usage ===" rg "DISTRICT_COURT_ASSISTANT" -A 3Length of output: 16570
apps/judicial-system/web/src/routes/Court/components/ReceptionAndAssignment/SelectCourtOfficials/SelectCourtOfficials.tsx (2)
5-5
: LGTM! Proper import added.The
isRequestCase
import is correctly added to support the new role validation logic.
77-79
: LGTM! Role validation enhanced.The condition correctly allows district court assistants to act as registrars in request cases while maintaining existing functionality.
apps/judicial-system/backend/src/app/modules/case/case.controller.ts (1)
203-203
: LGTM! The role expansion aligns with the PR objective.The addition of
UserRole.DISTRICT_COURT_ASSISTANT
to the list of allowed roles for registrar assignments is consistent with the goal of enabling district court assistants to act as registrars in R cases. The implementation maintains type safety and follows NestJS best practices.
Asana
What
Allow district court assistant to see and work on request cases in the same way a registrar can.
Why
Because they are supposed to be able to assist with performing the same actions as registrars.
Checklist:
Summary by CodeRabbit
Release Notes
New Features
Improvements
Access Control